Skip to content

chore: add docs, fail fast on execute for structural flawed solutions, make ScoreAnalysis not fail fact on structural flawed input - #2609

Merged
triceo merged 9 commits into
TimefoldAI:no-loopsfrom
Christopher-Chianelli:chore/structural-score-fail-fasts
Sep 1, 2026
Merged

chore: add docs, fail fast on execute for structural flawed solutions, make ScoreAnalysis not fail fact on structural flawed input#2609
triceo merged 9 commits into
TimefoldAI:no-loopsfrom
Christopher-Chianelli:chore/structural-score-fail-fasts

Conversation

@Christopher-Chianelli

Copy link
Copy Markdown
Contributor

For the record, I strongly dislike this change to ScoreAnalysis (returning with structural flaws instead of throwing an exception), and it will force the old implementation of the graph to live forever in some ways.

@triceo triceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving some comments.

Your comment about keeping the graph forever is noted. It is an implementation downside of a requirement which makes sense for users; we take the pain. Going forward, maybe we refactor the graph algorithm; it is fast becoming marginal, maybe we do not need all the incrementality anymore. Anyway, not for now.

* Return a collection of {@link ai.timefold.solver.core.api.domain.entity.PlanningEntity}
* that have inconsistent shadow variables.
*/
Collection<Object> getInconsistentEntities();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we separate this into individual loops?
IMO that would make some sense - it would allow for better debugging of what is looping.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, I would prefer if this returned a SequencedSet - clearer semantics, without having to explain.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It cannot be sequenced; loops are strongly connected components, and are not always of the form x1 -> x2 -> ... -> x1. There may be shortcuts:

  • x1 -> x2 -> x3 -> x4 -> x1, x1 -> y -> x1 and x2 -> y. Sequenced implies an ordering which is not possible for strongly connected components -- it is literally an "impossible to order" situlation.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not asking for any meaningful ordering. I am asking for reproducible ordering - the difference between HashSet and LinkedHashSet. Is that not possible?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can have reproducible ordering without exposing the type as Sequenced; the actual instance is LinkedHashSet.

Comment thread docs/src/modules/ROOT/pages/constraints-and-score/understanding-the-score.adoc Outdated

@triceo triceo left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have a naming issue to solve.
(Also, a bit of a confusion in terms.)

Other than that, I think we're good.

* @param variableName The variable on the entity.
*/
@NullMarked
public record EntityVariablePair(Object entity, String variableName) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will lead to a very verbose JSON.
I question if we need the variable information at all.
If we do, then arguably we can list entities per variable, as opposed to listing the variable with every entity.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want the individual loops, you need the variables, and the loop might be entity1:a -> entity2:b -> entity1:c.

@triceo
triceo merged commit 33fc4c7 into TimefoldAI:no-loops Sep 1, 2026
1 check passed
Christopher-Chianelli added a commit that referenced this pull request Sep 1, 2026
…, make ScoreAnalysis not fail fact on structural flawed input (#2609)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants